package cn.lu.train.view;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
import android.support.v4.widget.DrawerLayout;
import android.util.AttributeSet;
import android.view.KeyEvent;

public class MyDrawerLayout extends DrawerLayout {
    public MyDrawerLayout(@NonNull Context context) {
        super(context);
    }

    public MyDrawerLayout(@NonNull Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
    }

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        boolean backKeyAndVisibleDrawer = super.onKeyDown(keyCode, event);
        if (backKeyAndVisibleDrawer) {
            closeDrawers();
        }
        return backKeyAndVisibleDrawer;
    }
}
